<h1>
    <?=$this->title ?>
</h1>
<?
    if (!$this->is_add) // Edit Mode
    {
?>
<div id="right_menu">
    <ul>
<?
        $i = 0;
        foreach ($this->menu as $title => $action)
        {
            $i++;
            $container = ($action == 'edit' || $action == 'delete') ? 'inner' : 'container';
?>
        <li
<?
            if (count($this->menu) == $i)
                   echo "class=\"last\"";
            
            if ($this->action == $action)
                echo "class=\"active\"";
?>
            >
            <a href="#"
<?
            if ($action == 'delete')
            {
?>
                onClick="if(confirm('Sure?')) {ajaxAccounts({id: <?=$this->model_account->getID(); ?>,
                                                                        action: 'delete', 
                                                                        container: 'inner',
                                                                        company_id: <?=$this->model_account->getCompanyID() ?>
                                                                       }); return false;};"
<?
            }
            else
            {
?>
                onClick="ajaxAccounts({id: <?=$this->model_account->getID(); ?>,
                                       action: '<?=$action ?>',
                                       container: '<?=$container ?>',
                                       no_apply: true}); return false;"
<?
            }
?>
                ><?=$title ?></a>
	</li>
<?
        };
?>
    </ul>
</div>
<?
    }; //if (!$this->is_add)
?>
<div id="container" <? if ($this->is_add) echo "style = \"margin-top: -50px;\""; ?>>
    <div>
<?
        Principio_Library_Common::printErrorsAndMsg();
?>
        <table class="form_table">
            <tr>
                <td class="title">Login:</td>
                <td class="input_field">
                    <input type="text" id="account_login" value="<?=$this->model_account->getLogin(); ?>" />
                </td>
            </tr>
            <tr>
                <td class="title">Password:</td>
                <td class="input_field">
                    <input type="text" id="account_password" value="<?=$this->model_account->getPassword(); ?>" />
                </td>
            </tr>
            <tr>
                <td class="title">Display name:</td>
                <td class="input_field">
                    <input type="text" id="account_display_name" value="<?=$this->model_account->getDisplayName(); ?>" />
                </td>
            </tr>
            <tr>
                <td class="title">Short name:</td>
                <td class="input_field">
                    <input type="text" id="account_short_name" value="<?=$this->model_account->getShortName(); ?>" />
                </td>
            </tr>
            <tr>
                <td class="title">Company:</td>
                <td class="input_field">
                    <select id="account_company">
<?
                    foreach ($this->companies as $model_company)
                    {
?>
                        <option value="<?=$model_company->getID(); ?>"<? if ($this->model_account->getCompanyId() == $model_company->getID()) echo " selected"; ?>><?=$model_company->getCaption(); ?></option>
<? 	
                    };
?>
		</select>
                </td>
            </tr>
        </table>
	<table border="0" width="100%" class="buttons">
            <tr>
                <td align="right">
                    <input class="save" type="submit" name="apply" value="<?=($this->is_add ? "Add account" : "Apply changes") ?>"
                           onClick="ajaxAccounts({action: '<?=($this->is_add ? "add" : "edit") ?>',
                                                            container: 'inner' 
                                                            <? if (!$this->is_add) echo ", id: ".$this->model_account->getID(); ?>}); return false;"/>
                    <input class="cancel" type="submit" name="reset" value="Reset" onClick="<?=
                                                            ($this->is_add ? 
                                                                    "addItem({menu: 'accounts', container: 'inner', company_id: ".$this->model_account->getCompanyID()."})" :
                                                                    "ajaxAccounts({id: ".$this->model_account->getID().", action: 'edit', container: 'inner', no_apply: true})") ?>; return false;" />
                </td>
            </tr>
        </table>
    </div>
</div>